package com.atguigu.jedis.demos;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

/**
 * Created by Smexy on 2022/5/20
 */
public class JedisPoolDemo {

    public static void main(String[] args) {

        //用默认的配置，构建Jedisclient的连接池
        JedisPool jedisPool = new JedisPool("hadoop104", 6379);
        // 从池中获取(借)一个Jedis连接
        Jedis jedis = jedisPool.getResource();

        //写 set
        jedis.set("haha","xixi");

        //读 get
        String response = jedis.get("haha");

        //读一个不存在的key,返回值为null，不是""
        String response1 = jedis.get("afeaefaefa");

        System.out.println(response);
        System.out.println(response1);

        // 将连接还到池中
        jedis.close();

    }
}
